
package com.trp.service;

import android.os.Parcel;
import android.os.Parcelable;

public class QueryModelType implements Parcelable {

    public enum Type {
        SCALE(1), RECT(2), KV500(3), KV220(4), KV110(5), POLE(6), SUBSTATION(7), CIRCUIT(8), CIRCUIT_SECTION(
                9), UNKNOWN(0);

        private int value;

        private Type(int i) {
            value = i;
        }

        public static Type constructFromInt(int i) {
            switch (i) {
                case 1:
                    return SCALE;
                case 2:
                    return RECT;
                case 3:
                    return KV500;
                case 4:
                    return KV220;
                case 5:
                    return KV110;
                case 6:
                    return POLE;
                case 7:
                    return SUBSTATION;
                case 8:
                    return CIRCUIT;
                case 9:
                    return CIRCUIT_SECTION;
                default:
                    return UNKNOWN;
            }
        }
    }

    private Type mType;

    public Type getType() {
        return mType;
    }

    public QueryModelType(Type t) {
        this.mType = t;
    }

    public QueryModelType(Parcel source) {
        int type = source.readInt();
        this.mType = Type.constructFromInt(type);
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flag) {
        dest.writeInt(mType.ordinal());
    }

    public final static Parcelable.Creator<QueryModelType> CREATOR = new Parcelable.Creator<QueryModelType>() {
        public QueryModelType createFromParcel(Parcel source) {
            return new QueryModelType(source);
        }

        public QueryModelType[] newArray(int size) {
            return new QueryModelType[size];
        }
    };

}
